package fr.utbm.gi.in56.message;

import java.io.Serializable;
import java.util.Date;

/**
 * This class is an implementation of a message.
 *
 * @author Adrien Hoffer & Tarik Belabbas
 *
 */
public class Message implements Serializable
{
	/**
	 * Version number associated to the serializable class.
	 */
	private static final long	serialVersionUID	= 349189741920376035L;

	/**
	 * The message id
	 */
	private int 	id;
	
	/**
	 * The message recipient
	 */
	private String 	recipient;
	
	/**
	 * The message sender
	 */
	private String 	sender;
	
	/**
	 * The message subject
	 */
	private String 	subject;
	
	/**
	 * The message
	 */
	private String 	message;
	
	/**
	 * The message date
	 */
	private Date 	date;
	
	/**
	 * The concerned sell ad
	 */
	private int 	adSellId;
	
	/**
	 * The title of the sell ad
	 */
	private String adSellTitle;
	
	/**
	 * The concerned buy ad
	 */
	private int 	adBuyId;
	
	/**
	 * The title of the buy ad
	 */
	private String adBuyTitle;
	
	/**
	 * <tt>true</> if the message is ever read
	 */
	private boolean isRead;
	
	/**
	 * Default constructor
	 */
	public Message()
	{
		this.id 			= 0;
		this.recipient 		= ""; //$NON-NLS-1$
		this.sender 		= ""; //$NON-NLS-1$
		this.subject 		= ""; //$NON-NLS-1$
		this.message 		= ""; //$NON-NLS-1$
		this.date 			= null;
		this.adSellId		= 0;
		this.adBuyId 		= 0;
		this.isRead			= false;
		this.adBuyTitle		= ""; //$NON-NLS-1$
		this.adSellTitle	= ""; //$NON-NLS-1$
	}
	
	/**
	 * Parameterized constructor
	 * 
	 * @param _id the id
	 * @param _recipient the recipient
	 * @param _sender the sender
	 * @param _subject the subject
	 * @param _message the message
	 * @param _date the date
	 * @param _adSellId the concerning sell ad id
	 * @param _adBuyId the concerning buy ad id
	 * @param _adBuyTitle the title of the buy ad
	 * @param _adSellTitle the title of the sell ad
	 */
	public Message( int _id, String _recipient, String _sender, String _subject,
			String _message, Date _date, int _adSellId, int _adBuyId,
			boolean _isRead, String _adBuyTitle, String _adSellTitle )
	{
		this.id 			= _id;
		this.recipient 		= _recipient;
		this.sender 		= _sender;
		this.subject 		= _subject;
		this.message 		= _message;
		this.date 			= _date;
		this.adSellId		= _adSellId;
		this.adBuyId 		= _adBuyId;
		this.isRead 		= _isRead;
		this.adBuyTitle		= _adBuyTitle;
		this.adSellTitle	= _adSellTitle;
	}
	
	/**
	 * Returns the id
	 *
	 * @return the id
	 */
	public int getId()
	{
		return this.id;
	}
	
	/**
	 * Sets the id
	 *
	 * @param id the id to set
	 */
	public void setId( int id )
	{
		this.id = id;
	}
	
	/**
	 * Returns recipient
	 *
	 * @return the recipient
	 */
	public String getRecipient()
	{
		return this.recipient;
	}
	
	/**
	 * Sets the recipient
	 *
	 * @param recipient the recipient to set
	 */
	public void setRecipient( String recipient )
	{
		this.recipient = recipient;
	}
	
	/**
	 * Returns the sender
	 *
	 * @return the sender
	 */
	public String getSender()
	{
		return this.sender;
	}
	
	/**
	 * Sets the sender
	 *
	 * @param sender the sender to set
	 */
	public void setSender( String sender )
	{
		this.sender = sender;
	}
	
	/**
	 * Returns the subject
	 *
	 * @return the subject
	 */
	public String getSubject()
	{
		return this.subject;
	}
	
	/**
	 * Sets the subject
	 *
	 * @param subject the subject to set
	 */
	public void setSubject( String subject )
	{
		this.subject = subject;
	}
	
	/**
	 * Returns  the message
	 *
	 * @return the message
	 */
	public String getMessage()
	{
		return this.message;
	}
	
	/**
	 * Sets the message
	 *
	 * @param message the message to set
	 */
	public void setMessage( String message )
	{
		this.message = message;
	}
	
	/**
	 * Returns the date
	 *
	 * @return the date
	 */
	public Date getDate()
	{
		return this.date;
	}
	
	/**
	 * Sets the date
	 *
	 * @param date the date to set
	 */
	public void setDate( Date date )
	{
		this.date = date;
	}
	
	/**
	 * Returns the concerning sell add
	 *
	 * @return the adSellId
	 */
	public int getAdSellId()
	{
		return this.adSellId;
	}
	
	/**
	 * Sets the concerning sell ad
	 *
	 * @param adSellId the adSellId to set
	 */
	public void setAdSellId( int adSellId )
	{
		this.adSellId = adSellId;
	}
	
	/**
	 * Returns the concerning buy ad
	 *
	 * @return the adBuyId
	 */
	public int getAdBuyId()
	{
		return this.adBuyId;
	}
	
	/**
	 * Sets the concerning buy ad
	 *
	 * @param adBuyId the adBuyId to set
	 */
	public void setAdBuyId( int adBuyId )
	{
		this.adBuyId = adBuyId;
	}
	
	/**
	 * Returns <tt>false</tt> if the message is unread 
	 *
	 * @return <tt>false</tt> if the message is unread
	 */
	public boolean isRead()
	{
		return this.isRead;
	}
	
	/**
	 * Sets the boolean isRead: <tt>true</tt> to set that the message is read
	 *
	 * @param isRead <tt>true</tt> to set that the message is read
	 */
	public void setRead( boolean isRead )
	{
		this.isRead = isRead;
	}

	/**
	 * Sets the buy ad title
	 *
	 * @param adBuyTitle the adBuyTitle to set
	 */
	public void setAdBuyTitle( String adBuyTitle )
	{
		this.adBuyTitle = adBuyTitle;
	}

	/**
	 * Returns the buy ad title
	 *
	 * @return the adBuyTitle
	 */
	public String getAdBuyTitle()
	{
		return this.adBuyTitle;
	}

	/**
	 * Returns the title of the sell ad title
	 *
	 * @param adSellTitle the adSellTitle to set
	 */
	public void setAdSellTitle( String adSellTitle )
	{
		this.adSellTitle = adSellTitle;
	}

	/**
	 * Sets the title of the sell ad
	 *
	 * @return the adSellTitle
	 */
	public String getAdSellTitle()
	{
		return this.adSellTitle;
	}
}
